package com.hjs.homework.word_count

import org.apache.flink.streaming.api.scala._

object WordCountScalaStream {
  def main(args: Array[String]): Unit = {
    val ip = "bogon"
    val port = 7777
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    val streamData: DataStream[String] = env.socketTextStream(ip, port)
    val out: DataStream[(String, Int)] = streamData.flatMap(_.split(" ")).map((_, 1)).keyBy(0).sum(1)
    out.print
    env.execute
  }
}
